//Copyright 2010 Balazs Keri, Imre Keri
//
//This file is part of FireworksCreator.
//
//FireworksCreator is free software: you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.
//
//FireworksCreator is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with FireworksCreator.  If not, see <http://www.gnu.org/licenses/>.
//
#ifndef _PLAYERCONTROL_H
#define _PLAYERCONTROL_H
//
#include <QWidget>
//
class QSlider;
class QLineEdit;
class QLabel;
class QPushButton;
class PlayerControl:public QWidget
{
   Q_OBJECT
   Q_PROPERTY(bool isPlaying READ is_playing WRITE set_playing NOTIFY playing_changed)
   Q_PROPERTY(unsigned int currentTime READ get_current_time WRITE set_current_time NOTIFY current_time_changed)
   Q_PROPERTY(unsigned int startTime READ get_start_time WRITE set_start_time NOTIFY start_time_changed)
   Q_PROPERTY(unsigned int stopTime READ get_stop_time WRITE set_stop_time NOTIFY stop_time_changed)
   Q_PROPERTY(bool looping READ get_looping WRITE set_looping NOTIFY looping_changed)
//construction
public:
   PlayerControl(QWidget* parent=0,Qt::WindowFlags flags=0);
   virtual ~PlayerControl();
//signals
signals:
   void playing_changed(bool);
   void current_time_changed(unsigned int);
   void start_time_changed(unsigned int);
   void stop_time_changed(unsigned int);
   void looping_changed(bool);
//slots
public slots:
   void set_playing(bool playing);
   void set_current_time(unsigned int time);
   void set_start_time(unsigned int time);
   void set_stop_time(unsigned int time);
   void set_range(unsigned int start_time,unsigned int stop_time);
   void set_looping(bool looping);
protected slots:
   void current_time_changed(int time);
   void min_edit_edited();
   void max_edit_edited();
//state
public:
   bool is_playing() const;
   unsigned int get_current_time() const;
   unsigned int get_start_time() const;
   unsigned int get_stop_time() const;
   bool get_looping() const;
//data
protected:
   bool playing;
   unsigned int start_time;
   unsigned int stop_time;
   unsigned int current_time;
   bool looping;
   QSlider *time_slider;
   QLineEdit *min_edit,*max_edit;
   QLabel *time_label;
   QPushButton *playing_button;
   QPushButton *looping_button;
//util
private:
   static QString time_to_str(unsigned int time);
   static unsigned int str_to_time(const QString &str);
};
//
#endif